package com.jxin.oms.order.domain.inorder.service.impl;

import com.jxin.oms.order.domain.inorder.converter.InOrderConverter;
import com.jxin.oms.order.domain.inorder.converter.InOrderDetailConverter;
import com.jxin.oms.order.domain.inorder.dmo.entity.InOrder;
import com.jxin.oms.order.domain.inorder.repository.persistence.IInOrderRepository;
import com.jxin.oms.order.domain.inorder.service.ISaveInOrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * 保存原始单的领域服务 实现类
 * @author Jxin
 * @version 1.0
 * @since 2020/1/20 16:43
 */
@Service
public class SaveInOrderService implements ISaveInOrderService {
    @Autowired
    private IInOrderRepository inOrderRepository;
    /**
     * 持久化 原始单实体
     * @param  inOrder 原始单 实体
     * @author Jxin
     */
    @Override
    @Transactional
    public void saveInOrder(InOrder inOrder) {
        inOrderRepository.insert(InOrderConverter.convertToInOrderDo(inOrder),
                                 InOrderDetailConverter.convertToInOrderDetailDoList(inOrder.getDetailList()));
    }
}
